<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>主题截图编辑</title>
    <link rel="shortcut icon" href="/images/index/logo.ico">
    <style>
        .refresh {
            display: inline-block;
            float: right;
        }
    </style>
</head>
<body>
<div class="refresh">
    <button class="btn btn-info search" title="刷新" data-url="/themeScreenshot/user/list?tid=${param.tid}"><span
            class="glyphicon glyphicon-refresh"></span></button>
</div>
<div class="">
    <ol class="breadcrumb">
        <li><a href="javascript:;">主题案例管理</a></li>
        <li><a data-url="/themeAdmin/user/list">主题上传</a></li>
        <li class="active">主题截图编辑</li>
    </ol>
</div>
<span id="data-tid" hidden>${param.tid}</span>
<div class="screenshot_show">
    <table class="table table-bordered table-responsive">
        <tr>
            <th>id</th>
            <th>截图</th>
            <th>截图标题</th>
            <th>截图标题英文</th>
            <th>截图主题创意</th>
            <th>背景颜色值(16进制)</th>
            <th>操作</th>
        </tr>
        <c:forEach var="data" items="${dataMap}">
            <tr>
                <td class="id">${data.id}</td>
                <td><img src="/themeScreenshot/user/image?tid=${param.tid}&image=${data.image}"
                         data-image="${data.image}" alt="" width="200px"
                         height="400px">
                    <input type="file" class="hidden" accept="image/png,image/gif,image/jpg" name="image">
                </td>
                <td><p>${data.name}</p></td>
                <td><p>${data.sname}</p></td>
                <td><p>${data.content}</p></td>
                <td><p style="color: ${data.color}">${data.color}</p></td>
                <td class="operate">
                    <button class=" btn btn-info top">上移</button>
                    <button class=" btn btn-primary down">下移</button>
                    <button class=" btn btn-danger delete">删除</button>
                </td>
            </tr>
        </c:forEach>
    </table>
</div>

<button class="btn btn-info add" data-url="/themeScreenshot/user/add?tid=${param.tid}">
    <span class="glyphicon glyphicon-plus"></span> 添加
</button>
<button class="btn btn-primary save" style="margin-right: 15px">
    <span class="glyphicon glyphicon-plus"></span> 提交
</button>
<script>
    $(document).ready(function () {
        $('.search').click(function () {
            var scope = $(this);
            $('.content_right').load(scope.attr('data-url'));
            toast_text('刷新成功', 600);
        });
        $('.breadcrumb a').click(function () {
            if ($(this).attr('data-url')) {
                $('.content_right').load($(this).attr('data-url'));
            }
        });
        img_click(1, '/themeScreenshot/user/changeThemeScreenshotInfoAdmin', "/themeScreenshot/user/changeThemeScreenshotAdmin");

        $('.add').click(function () {

            $('.content_right').load($(this).attr("data-url"));
        });

        p_click('/themeScreenshot/user/changeThemeScreenshotInfoAdmin');


//删除操作
        $('.delete').click(function () {
            var tid = $("#data-tid").text();
            var scope = $(this);
            var id = $(this).parent().siblings('.id').text();
            custom_modal('你确定要删除么？');
            $('.modal_footer button').eq(0).unbind().click(function () {
                $.post("/themeScreenshot/user/delete", {id: id, tid: tid}, function (data) {
                    if (data.code == 200) {
                        scope.parents('tr').remove();
                    }
                    $('.modal_1').fadeOut();
                    toast_text(data.msg, 600);
                })
            });

        });
//        排序操作
        var save_id = [];
        $('.save').click(function () {
            $('.table tr').each(function (index, elem) {
                if (index > 0) {
                    save_id.push($(elem).find('td').eq(0).text());
                }
            });
            $.post("/themeScreenshot/user/changeThemeScreenshotSoftAdmin", {id: save_id.join(",")}, function (data) {
                if (data.code == 200) {
                    toast_text(data.msg, 3000);
                }
            });
        });


    });
</script>
</body>
</html>